package cn.etg.product2503.common;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

/*
创建统一返回结果集
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
public class Result<T> {
    // 状态码
    private Integer code;
    //提示信息
    private String message;
    //携带数据
    private T data;
    /**
     *
     * @param
     * @return <E> Result<E> 带有泛型的返回值类型
     * @param <E>
     */
    public static <E> Result<E> success(String message, E data) {
        return new Result<>(200, message, data);
    }
    public static Result success(String message) {
        return new Result<>(200, message, null);
    }
    public static Result error( String message) {
        return new Result<>(1, message, null);
    }
    public static Result error(Integer code, String message) {
        return new Result<>(code, message, null);
    }
}
